<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
	<title>客户资源管理系统</title>
	<!-- 标签图标设置 -->
	<link rel="icon" href="images/favicon.ico" type="image/ico">
	<!-- SEO（搜索引擎所有关键件） -->
	<meta name="keywords" content="crm,qf">
	<meta name="description" content="这是一个解决中小企业客户资源管理的网站">
	<meta name="author" content="枫桥夜泊1990">
	<link href="${pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath }/css/materialdesignicons.min.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath }/css/style.min.css" rel="stylesheet">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/js/jconfirm/jquery-confirm.min.css">
</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <aside class="lyear-layout-sidebar">
      
      <!-- logo -->
      <div id="logo" class="sidebar-header">
        <a href="index.html"><img src="images/logo-sidebar.png" title="LightYear" alt="LightYear" /></a>
      </div>
      <div class="lyear-layout-sidebar-scroll"> 
        
        <!-- 左侧菜单栏start -->
        <jsp:include page="common/menus.jsp"></jsp:include>
        <!-- 左侧菜单栏end -->
        
         <div class="sidebar-footer">
           <p class="copyright">Copyright &copy; 2020. <img style="width: 25px;padding-bottom: 5px;" src="images/fy.png" /> <a target="_blank" href="https://hd1611756908.github.io/"> CRM</a>&nbsp; Powered By &nbsp;<a href="https://space.bilibili.com/514155929/" target="_blank" title="枫桥夜泊">枫桥夜泊</a></p>
         </div>
      </div>
      
    </aside>
    <!--End 左侧导航-->
    
    <!--头部信息-->
    <header class="lyear-layout-header">
      
      <nav class="navbar navbar-default">
        <div class="topbar">
          
          <div class="topbar-left">
            <div class="lyear-aside-toggler">
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
            </div>
            <span class="navbar-page-title"> 合同 - 合同列表 </span>
          </div>
          
          <ul class="topbar-right">
          
              <jsp:include page="common/ABC.jsp"></jsp:include>
            <!--切换主题配色-->
		    <li class="dropdown dropdown-skin">
			  <span data-toggle="dropdown" class="icon-palette"><i class="mdi mdi-palette"></i></span>
			  <ul class="dropdown-menu dropdown-menu-right" data-stopPropagation="true">
                <li class="drop-title"><p>主题</p></li>
                <li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="site_theme" value="default" id="site_theme_1" checked>
                    <label for="site_theme_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="site_theme" value="dark" id="site_theme_2">
                    <label for="site_theme_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="site_theme" value="translucent" id="site_theme_3">
                    <label for="site_theme_3"></label>
                  </span>
                </li>
			    <li class="drop-title"><p>LOGO</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="logo_bg" value="default" id="logo_bg_1" checked>
                    <label for="logo_bg_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_2" id="logo_bg_2">
                    <label for="logo_bg_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_3" id="logo_bg_3">
                    <label for="logo_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_4" id="logo_bg_4">
                    <label for="logo_bg_4"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_5" id="logo_bg_5">
                    <label for="logo_bg_5"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_6" id="logo_bg_6">
                    <label for="logo_bg_6"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_7" id="logo_bg_7">
                    <label for="logo_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_8" id="logo_bg_8">
                    <label for="logo_bg_8"></label>
                  </span>
				</li>
				<li class="drop-title"><p>头部</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="header_bg" value="default" id="header_bg_1" checked>
                    <label for="header_bg_1"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_2" id="header_bg_2">
                    <label for="header_bg_2"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_3" id="header_bg_3">
                    <label for="header_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="header_bg" value="color_4" id="header_bg_4">
                    <label for="header_bg_4"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_5" id="header_bg_5">
                    <label for="header_bg_5"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_6" id="header_bg_6">
                    <label for="header_bg_6"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_7" id="header_bg_7">
                    <label for="header_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="header_bg" value="color_8" id="header_bg_8">
                    <label for="header_bg_8"></label>
                  </span>
				</li>
				<li class="drop-title"><p>侧边栏</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="sidebar_bg" value="default" id="sidebar_bg_1" checked>
                    <label for="sidebar_bg_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_2" id="sidebar_bg_2">
                    <label for="sidebar_bg_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_3" id="sidebar_bg_3">
                    <label for="sidebar_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_4" id="sidebar_bg_4">
                    <label for="sidebar_bg_4"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_5" id="sidebar_bg_5">
                    <label for="sidebar_bg_5"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_6" id="sidebar_bg_6">
                    <label for="sidebar_bg_6"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_7" id="sidebar_bg_7">
                    <label for="sidebar_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_8" id="sidebar_bg_8">
                    <label for="sidebar_bg_8"></label>
                  </span>
				</li>
			  </ul>
			</li>
            <!--切换主题配色-->
          </ul>
          
        </div>
      </nav>
      
    </header>
    <!--End 头部信息-->
    
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        
        <div class="row">
		  <div class="col-lg-12">
			<div class="card">
			  <div class="card-toolbar clearfix">
				<form class="pull-right search-bar" method="get" action="#!" role="form">
				  <div class="input-group">
					<input type="text" class="form-control" value="" name="keyword" placeholder="请输入合同">
					<div class="input-group-btn">
					  <button class="btn btn-dark" type="button">搜索</button>
					</div>
				  </div>
				</form>
				<div class="toolbar-btn-action">
				  <a class="btn btn-primary m-r-5" href="${pageContext.request.contextPath }/ContractAddJumpServlet"><i class="mdi mdi-plus"></i> 新增</a>
				  <a id="btnDel" class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
				</div>
			  </div>
			  <div class="card-body">
				
				<div class="table-responsive">
				  <table class="table table-hover">
					<thead>
					  <tr>
						<th>
						  <label class="lyear-checkbox checkbox-primary">
							<input type="checkbox" id="check-all"><span></span>
						  </label>
						</th>
						<th>合同编号</th>
						<th>合同名称</th>
						<th>客户名称</th>
						<th>合同金额</th>
						<th>生效时间</th>
						<th>结束时间</th>
						<th>客户签约人</th>
						<th>公司签约人</th>
						<th>负责人</th>
						<th>审批人1</th>
						<th>审批人2</th>
						<th>状态</th>
					  </tr>
					</thead>
					<tbody id="contract_tbody">
					
					
	
			
			
			
					</tbody>
				  </table>
				</div>
				<ul class="pagination">
				  <li class="disabled"><span>«</span></li>
				  <li class="active"><span>1</span></li>
				  <li><a href="#1">2</a></li>
				  <li><a href="#1">3</a></li>
				  <li><a href="#1">4</a></li>
				  <li><a href="#!">»</a></li>
				</ul>
	   
			  </div>
			</div>
		  </div>
		  
		</div>
       
     
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<!-- 合同状态start -->
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="gridSystemModal">
  <div class="modal-dialog" role="document">
	<div class="modal-content">
	  <div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		<h4 class="modal-title" id="gridSystemModalLabel">合同信息</h4>
	  </div>
	  <div class="modal-body">
		<div class="row">
		  <div class="col-md-12">
			  <ul class="nav-step step-anchor">
				<li class="nav-step-item complete">
				  <a href="#step-1">
					<h6>张三</h6>
					<p class="m-0">已审批</p>
				  </a>
				</li>
				<li class="nav-step-item active">
				  <a href="#step-2">
					<h6>李四</h6>
					<p class="m-0">已审批</p>
				  </a>
				</li>
				<li class="nav-step-item">
				  <a href="#step-3">
					<h6>王五</h6>
					<p class="m-0">待审批</p>
				  </a>
				</li>
			  </ul>
		  </div>
		</div>
		<div class="modal-header">
			<h4 class="modal-title" id="gridSystemModalLabel">产品列表</h4>
		</div>
		<div class="row">
		  <div class="col-md-12">
			  <table class="table">
				<thead>
				  <tr>
					<th>产品名称</th>
					<th>产品编号</th>
					<th>价格</th>
					<th>数量</th>
					<th>合计</th>
				  </tr>
				</thead>
				<tbody>
				  <tr>
					<th>小米10</th>
					<td>xm100001</td>
					<td>200</td>
					<td>10</td>
					<td>2000</td>
				  </tr>
				</tbody>
			  </table>
		  </div>
		</div>
	  </div>
	</div>
  </div>
</div>
<!-- 合同状态end -->

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/main.min.js"></script>
<!--图表插件-->
<script type="text/javascript" src="${pageContext.request.contextPath }/js/Chart.js"></script>
<script src="${pageContext.request.contextPath }/js/jconfirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/pdfobject.min.js"></script>
<script type="text/javascript">
	
	/* 查看pdf文件 */
	$(".contractClass").click(function(){
		PDFObject.embed(this.href);
	});
	
	/*     */
	
	$(function(){
		
	
	    var productID = null;
		
	    var arr = [];
	    
	    /*      导出     */
		$('#downLoad').on('click', function () {
			
			/* 			var arr3=new Array(10);  */ 
						//获取被选中的多选框
						
						var cks = $("input[type='checkbox']:checked").not($("#check-all"));
						
						for(var i=0;i<cks.length;i++){
							console.log(cks[i].value);	
						}
						
					    $.confirm({
					        title: '导出',
					        content: '是否确认导出?',
					        type: 'green',
					        typeAnimated: true,
					        buttons: {
					            tryAgain: {
					                text: '确认',
					                btnClass: 'btn-red',
					                action: function(){
					                	
										//当点击确认删除时被执行
										console.log('确认导出....');	
				                    
										for(var i=0;i<cks.length;i++){
											
											arr[i]=cks[i].value;
											
											console.log(arr[i]);
											
										}
										
										 $.ajax({
									            type: "post", 
									            url:"ProductDownLoadExcelServlet",
									            data: {"arr":arr},
									            dataType:"json", 
									            success:function(d){
									              
									            },
										            traditional :true,//阻止jq的深度序列化 
										            error:function(data){          
									            }
									            
									            }); 
													
										
						
					                }
					            },
					            close: {
					                text: '关闭'
					            }
					        }
					    });
					});
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		/* 删除提示框生成 */
		
		$('#btnDel').on('click', function () {
			
/* 			var arr3=new Array(10);  */ 
			//获取被选中的多选框
			
			var cks = $("input[type='checkbox']:checked").not($("#check-all"));
			
			for(var i=0;i<cks.length;i++){
				console.log(cks[i].value);	
			}
			
		    $.confirm({
		        title: '删除',
		        content: '是否确认删除?',
		        type: 'red',
		        typeAnimated: true,
		        buttons: {
		            tryAgain: {
		                text: '确认',
		                btnClass: 'btn-red',
		                action: function(){
							//当点击确认删除时被执行
							console.log('确认删除....');
							
	/*  */	
	                    
							for(var i=0;i<cks.length;i++){
								
								productID=cks[i].value;
								
 								console.log(productID);
								
								$.getJSON("${pageContext.request.contextPath }/ProductDelectJsonServlet",{productID:productID},function(d){					
									console.log("d=",d);
									  if(d.code == 200){
										  //删除成功    跳转到  列表    
										  window.location.href="product_list.jsp";
									  }

									
		
								});	 
										
							}
			
		                }
		            },
		            close: {
		                text: '关闭'
		            }
		        }
		    });
		});
		
		
		
	});
	
	
	
	
	//  使用 AJAX 分页数据 
	var pageNO = 1;
	var pageSize = 2;
	var pageCount = null;

	$.getJSON("${pageContext.request.contextPath }/ContractListServlet",{pageNO:pageNO,pageSize:pageSize},function(d){
		
   	    console.log(d);        
		
		pageCount = d.pageCount;
		
/* 		console.log(pageCount); */
		
		var str="";
		for(var i=0;i<d.object.length;i++){
			
			str+="					  <tr>\r\n" + 
			"						<td>\r\n" + 
			"						  <label class=\"lyear-checkbox checkbox-primary\">\r\n" + 
			"							<input type=\"checkbox\" name=\"ids[]\" value=\""+d.object[i].contractID+"\"><span></span>\r\n" + 
			"						  </label>\r\n" + 
			"						</td>\r\n" + 
			"						<td><a href=\"#\" data-toggle=\"modal\" data-target=\"#gridSystemModal\">"+d.object[i].contractID+"</a></td>\r\n" + 
			"						<td><a class=\"contractClass\" href=\"JavaWeb.pdf\">"+d.object[i].contractName+"</a></td>\r\n" + 
			"						<td>"+d.object[i].customer.customerName+"</td>\r\n" + 
			"						<td>"+d.object[i].contractMoney+"</td>\r\n" + 
			"						<td>"+d.object[i].startTime+"</td>\r\n" + 
			"						<td>"+d.object[i].endTime+"</td>\r\n" + 
			"						<td>"+d.object[i].customerSigner+"</td>\r\n" + 
			"						<td>"+d.object[i].employeeSigner.employeeName+"</td>\r\n" + 
			"						<td>"+d.object[i].employeeResponsible.employeeName+"</td>\r\n" + 
			"						<td>"+d.object[i].employee01.employeeName+"</td>\r\n" + 
			"						<td>"+d.object[i].employee02.employeeName+"</td>\r\n" + 
			"						<td>"+Tflag(d.object[i].flag)+"</td>\r\n" + 
			"					  </tr>";
			
			         
		}
		
	    $("#contract_tbody").html(str);
	    
	    joinPage(pageNO,pageCount);
		
	    currentPage(pageNO,".currentPage");
	    
	    bindPage(pageNO,pageSize)
	    
	    
	/*                         选框                     */
	
	var $items = $("input[name='ids[]']");
	console.log($items);
	// 全选框     
	var checkAllBtn = ($("#check-all"));

	// 判断 全选和全不部选
	for (var i = 0; i < $items.length; i++) {
		$($items[i]).click(function(){

				//默认全给选中
				checkAllBtn[0].checked = true;
				//如果发现有一个没选中,取消全选
				for (var j = 0; j < $items.length; j++) {
					if (!$items[j].checked) {                    /* 当发现有一个时 false 执行 if 判断语句   将全选款 checked = false  */
						checkAllBtn[0].checked = false;
						break;
					}
				}

			});
	
		}
	    
	    
	    
	    
	    
	    
	    
	    
	});
	
	
	function bindPage(pageNO,pageSize){
		 
		 
		 
		 // 绑定中间页
		 
		 var cps=$(".currentPage");
		
		 for(var i=0;i<cps.length;i++){
			 $(cps[i]).click(function(){
				 pageNO=parseInt(this.innerHTML);
				 
				 
				 
				 
				 
				 $.getJSON("${pageContext.request.contextPath }/ContractListServlet",{pageNO:pageNO,pageSize:pageSize},function(d){
						
				   	    console.log(d);        
						
						pageCount = d.pageCount;
						
				/* 		console.log(pageCount); */
						
						var str="";
						for(var i=0;i<d.object.length;i++){
							
							str+="					  <tr>\r\n" + 
							"						<td>\r\n" + 
							"						  <label class=\"lyear-checkbox checkbox-primary\">\r\n" + 
							"							<input type=\"checkbox\" name=\"ids[]\" value=\""+d.object[i].contractID+"\"><span></span>\r\n" + 
							"						  </label>\r\n" + 
							"						</td>\r\n" + 
							"						<td><a href=\"#\" data-toggle=\"modal\" data-target=\"#gridSystemModal\">"+d.object[i].contractID+"</a></td>\r\n" + 
							"						<td><a class=\"contractClass\" href='http://localhost:8080/crm"+d.object[i].contractURl+"'>"+d.object[i].contractName+"</a></td>\r\n" + 
							"						<td>"+d.object[i].customer.customerName+"</td>\r\n" + 
							"						<td>"+d.object[i].contractMoney+"</td>\r\n" + 
							"						<td>"+d.object[i].startTime+"</td>\r\n" + 
							"						<td>"+d.object[i].endTime+"</td>\r\n" + 
							"						<td>"+d.object[i].customerSigner+"</td>\r\n" + 
							"						<td>"+d.object[i].employeeSigner.employeeName+"</td>\r\n" + 
							"						<td>"+d.object[i].employeeResponsible.employeeName+"</td>\r\n" + 
							"						<td>"+d.object[i].employee01.employeeName+"</td>\r\n" + 
							"						<td>"+d.object[i].employee02.employeeName+"</td>\r\n" + 
							"						<td>"+Tflag(d.object[i].flag)+"</td>\r\n" + 
							"					  </tr>";
							
							         
						}
						
					    $("#contract_tbody").html(str);
					    
					    joinPage(pageNO,pageCount);
						
					    currentPage(pageNO,".currentPage");
					    
					    bindPage(pageNO,pageSize)
							    
							});
				 
				 
			 });
			 
			 
		 }
		 
		 
		 
		 
		 
		//  绑定上一页	 
		$("#pre").click(function(){
			
			if(pageNO<=1){
				
				alert("已经是最后一页了");
				
			}else{
				pageNO=pageNO-1;
				
				
				$.getJSON("${pageContext.request.contextPath }/ContractListServlet",{pageNO:pageNO,pageSize:pageSize},function(d){
					
			   	    console.log(d);        
					
					pageCount = d.pageCount;
					
			/* 		console.log(pageCount); */
					
					var str="";
					for(var i=0;i<d.object.length;i++){
						
						str+="					  <tr>\r\n" + 
						"						<td>\r\n" + 
						"						  <label class=\"lyear-checkbox checkbox-primary\">\r\n" + 
						"							<input type=\"checkbox\" name=\"ids[]\" value=\""+d.object[i].contractID+"\"><span></span>\r\n" + 
						"						  </label>\r\n" + 
						"						</td>\r\n" + 
						"						<td><a href=\"#\" data-toggle=\"modal\" data-target=\"#gridSystemModal\">"+d.object[i].contractID+"</a></td>\r\n" + 
						"						<td><a class=\"contractClass\" href=\"JavaWeb.pdf\">"+d.object[i].contractName+"</a></td>\r\n" + 
						"						<td>"+d.object[i].customer.customerName+"</td>\r\n" + 
						"						<td>"+d.object[i].contractMoney+"</td>\r\n" + 
						"						<td>"+d.object[i].startTime+"</td>\r\n" + 
						"						<td>"+d.object[i].endTime+"</td>\r\n" + 
						"						<td>"+d.object[i].customerSigner+"</td>\r\n" + 
						"						<td>"+d.object[i].employeeSigner.employeeName+"</td>\r\n" + 
						"						<td>"+d.object[i].employeeResponsible.employeeName+"</td>\r\n" + 
						"						<td>"+d.object[i].employee01.employeeName+"</td>\r\n" + 
						"						<td>"+d.object[i].employee02.employeeName+"</td>\r\n" + 
						"						<td>"+Tflag(d.object[i].flag)+"</td>\r\n" + 
						"					  </tr>";
						
						         
					}
					
				    $("#contract_tbody").html(str);
				    
				    joinPage(pageNO,pageCount);
					
				    currentPage(pageNO,".currentPage");
				    
				    bindPage(pageNO,pageSize)
						    
						}); 
				
				
				
			}
	
		});	 
		 
		 
	 
	 //  绑定下一页
	 $("#next").click(function(){
		 
		 if(pageNO>=pageCount){
			 
			 alert("已经是最后一页了");
			 
		 }else{
			 
			 pageNO=pageNO+1;
			 
			 $.getJSON("${pageContext.request.contextPath }/ContractListServlet",{pageNO:pageNO,pageSize:pageSize},function(d){
					
			   	    console.log(d);        
					
					pageCount = d.pageCount;
					
			/* 		console.log(pageCount); */
					
					var str="";
					for(var i=0;i<d.object.length;i++){
						
						str+="					  <tr>\r\n" + 
						"						<td>\r\n" + 
						"						  <label class=\"lyear-checkbox checkbox-primary\">\r\n" + 
						"							<input type=\"checkbox\" name=\"ids[]\" value=\""+d.object[i].contractID+"\"><span></span>\r\n" + 
						"						  </label>\r\n" + 
						"						</td>\r\n" + 
						"						<td><a href=\"#\" data-toggle=\"modal\" data-target=\"#gridSystemModal\">"+d.object[i].contractID+"</a></td>\r\n" + 
						"						<td><a class=\"contractClass\" href=\"JavaWeb.pdf\">"+d.object[i].contractURl+"</a></td>\r\n" + 
						"						<td>"+d.object[i].customer.customerName+"</td>\r\n" + 
						"						<td>"+d.object[i].contractMoney+"</td>\r\n" + 
						"						<td>"+d.object[i].startTime+"</td>\r\n" + 
						"						<td>"+d.object[i].endTime+"</td>\r\n" + 
						"						<td>"+d.object[i].customerSigner+"</td>\r\n" + 
						"						<td>"+d.object[i].employeeSigner.employeeName+"</td>\r\n" + 
						"						<td>"+d.object[i].employeeResponsible.employeeName+"</td>\r\n" + 
						"						<td>"+d.object[i].employee01.employeeName+"</td>\r\n" + 
						"						<td>"+d.object[i].employee02.employeeName+"</td>\r\n" + 
						"						<td>"+Tflag(d.object[i].flag)+"</td>\r\n" + 
						"					  </tr>";
						
						         
					}
					
				    $("#contract_tbody").html(str);
				    
				    joinPage(pageNO,pageCount);
					
				    currentPage(pageNO,".currentPage");
				    
				    bindPage(pageNO,pageSize)
						    
						}); 
			 
			 
			 
			 
		 }

	 });
		 
	 
}
	
	
	
	
	// 当前页的颜色
	function currentPage(pageNO,currentPage){
		
		var c =$(currentPage);
		
		 for(var i=0;i<c.length;i++){
			 var cp=c[i].innerHTML;              /* innerHTML  拿到当前页码 */
			 if(pageNO==cp){                              /* 如果当前页  比较 如果是当前页  就添加样式         */
				// c[i].style.cssText="color:red";
				 c[i].style.cssText="color:red";         
			 }		 
		 }
		
	}
	
	
	// 显示页
	function joinPage(pageNO,pageCount){
		
		//  上一页
		var str="<li><span id='pre'>«</span></li>";
		
		if(pageCount<=3){
			for(var i=1;i<=pageCount;i++){
				str += "<li><a class='currentPage' href=\"#1\">"+i+"</a></li>";
			}
		}else{
			if(pageNO<=3){
				for(var i=1;i<=3;i++){
					str +="<li><a class='currentPage' href=\"#1\">"+i+"</a></li>";
				}
			}else{
				for(var i=pageNO-2;i<=pageNO;i++){
					str +="<li><a class='currentPage' href=\"#1\">"+i+"</a></li>";
				}
			}
		}
		
		// 下一页
		str +="<li><span id='next'>»</span></li>";  
		
		$(".pagination").html(str);
	}
	
	
	//  判断flag
	
	function Tflag(flag){
		
		if(flag==0){
			return "已提交";
		}else if(flag == 2 || flag == 4){
			return "未通过";
		}else if(flag == 1){
			return "审批人1通过";
		}else {
			return "审批人2通过";
		}
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
</script>
</body>
</html>